package com.jerry.security.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

/**
 * @author Jerry.Wu
 * @description:
 * @date 2018/8/29 18:24
 */
@Data
@Entity
@Table(name = "t_user")
public class User extends IdEntity{

    private static final long serialVersionUID = 1L;

    private String username;

    private String password;

    private String nickname;

    private Integer age;

    private Integer sex;

    private String email;

    private Boolean enabled;

    @ManyToMany(cascade = {CascadeType.MERGE})
    @JsonIgnore
    @JoinTable(name = "t_user_role",
            joinColumns = { @JoinColumn(name = "userId", referencedColumnName = "id") },
            inverseJoinColumns = { @JoinColumn(name = "roleId", referencedColumnName = "id") })
    private List<Role> roles;

}
